<?php
/*
 +----------------------------------------------------------------------
 + Title        : FeedbackLogic 控制器
 + Author       : Randy_chen
 + Version      : V1.0.0.1
 + Initial-Time : 2021/3/2 6:59
 + Last-time    : 2021/3/2 6:59+ chen2
 + Desc         : FeedbackLogic
 +----------------------------------------------------------------------
*/


namespace app\common\service;

use app\common\model\Banner;

class BannerService
{

    public function getBannerList($data)
    {
        return Banner::build()
                     ->equal('status')
                     ->order('create_time desc')
                     ->_paginate();
    }

    public function getBannerItem($id)
    {
        return Banner::build()
                     ->where('id', $id)
                     ->findOrFail();
    }

    public function setBannerItem($data)
    {
        $model = Banner::where('id', $data['id'])
                       ->findOrFail();
        $model->save($data);
        return $model;
    }

    public function addBannerItem($data, $admin_id)
    {
        $model = new Banner();
        $data['admin_uuid'] = $admin_id;
        $model->save($data);
        return $model;
    }

    public function delBannerItem($id)
    {
        $banner = Banner::build()
                        ->findOrFail($id);
        return $banner->delete();
    }
}